<?php
declare(strict_types=1);

namespace WebApp\lib\db\mysql;

/**
 * Interface ITable
 */
interface ITable
{
    /**
     * @param $arr
     * @return object
     */
    public function transaction($arr);

    /**
     * @param string $sql
     * @param array $data
     * @return mixed
     */
    public function getObjArrBySql(string $sql, $data=[]);

    /**
     * @param string $sql
     * @param array $data
     * @return mixed
     */
    public function getObjBySql(string $sql, $data=[]);

    /**
     * @param $dbName
     * @param array $data
     * @param array $where
     * @return mixed
     */
    public function updateObj($dbName, $data = [], $where = []);

    /**
     * @param $dbName
     * @param array $where
     * @return mixed
     */
    public function removeObj($dbName, $where = []);

    /**
     * @param $dbName
     * @param array $data
     * @return mixed
     */
    public function replaceObj($dbName, $data = []);

    /**
     * @param $dbName
     * @param array $data
     * @return mixed
     */
    public function addObj($dbName, $data = []);

    /**
     * @param $dbName
     * @param array $where
     * @return mixed
     */
    public function getObjCount($dbName, $where = []);

    /**
     * @param $dbName
     * @param array $need
     * @param array $where
     * @param string $group
     * @param string $sort
     * @param string $limit
     * @return mixed
     */
    public function getObjArr($dbName, $need = [], $where = [], $group = '', $sort = '', $limit = '');
    public function getObjArrV1(&$rows, string $dbName, $select, array $where = [], string $group = '', $sort = '', array $limit = []);

    /**
     * @param $dbName
     * @param array $need
     * @param array $where
     * @param string $group
     * @param string $sort
     * @return mixed
     */
    public function getObj($dbName, $need = [], $where = [], $group = '', $sort = '');
    public function getObjV1(&$row, $dbName, $select, array $where = [], $group = '', $sort = '');

    /**
     * @param $data
     * @return mixed
     */
    public static function makeSetData(&$data);

    /**
     * @param $where
     * @return mixed
     */
    public static function makeWhere(&$where);

    /**
     * @param string $_sql
     * @return mixed
     */
    public function execute(string $_sql);

    public function getLastSql();
    public function getLastId();
    public function getLastErrInfo(): string;
    public function getLastErrCode(): string;
    public function getLastParams(): array ;

    public function setLastSql($sql);
    public function setLastId($id);
    public function setLastParams($params);
    public function setLastErrInfo(string $info);
    public function setLastErrCode($code);

    public function clear();
}
